package com.spzx.product.api.fallback;

import com.spzx.common.core.domain.R;
import com.spzx.product.api.ProductFeignClient;
import com.spzx.product.api.domain.Product;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * @ClassName ProductFeignClientFallbackFactory
 * @Author 波
 * @Date 2024/8/5 20:41
 */
@Slf4j
public class ProductFeignClientFallbackFactory implements FallbackFactory<ProductFeignClient> {
    @Override
    public ProductFeignClient create(Throwable cause) {
        log.error("商品服务调用失败"+cause.getMessage());
        return new ProductFeignClient() {
            @Override
            public R<Product> selectProductById(Long pid, String source) {
                return R.fail("获取商品信息失败:" + cause.getMessage());
            }
        };
    }
}
